//
//  key.h
//  smart_garbage_case
//
//  Created by fukai on 2018/10.
//  Copyright © 2018年 Cyber01. All rights reserved.
//

#ifndef key_h
#define key_h



//定义按键读取端口
#define KEY0  GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_8)//读取按键0
#define KEY1  GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_9)//读取按键0
#define KEY2  GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_10)//读取按键0
#define KEY3  GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_11)//读取按键0
#define KEY4  GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_12)//读取按键0
#define KEY5  GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_15)//读取按键0

//定义按键状态
#define KEY_ON		0	//按键按下
#define KEY_OFF		1	//按键松开

//按键功能
typedef enum
{
	KEY_NULL = 0,	//无按键按下
	KEY_START,	//菜单键
	KEY_MENU,	//返回键
	KEY_DIRECTION_UP,//方向上键
	KEY_DIRECTION_DOWN,//方向下键
	KEY_ADD,//加
	KEY_DECREASE,//减
}KeyModeNode;

//按键结构体
typedef struct
{
	unsigned char long_press_mode;	//按键长按模式启动,1为长按启动，0为长按关闭
	unsigned char long_press_check;	//按键长按检查
	unsigned char long_press_time;	//按键长按检测时间
	
	KeyModeNode KeyValue;
}KeyMessageNode;


extern KeyMessageNode KeyMessage;

void KeyInit(void);	//按键初始化函数
void KeyContinuousCheck(void);	//按键长按检测
KeyModeNode KeyScan(void);	//按键扫描
void DebugC(char *Regulated_quantity,char number);
void DebugI(int *Regulated_quantity,int number);
void DebugD(double *Regulated_quantity,double number);
void DebugF(float *Regulated_quantity,float number);


#endif


